<?php
/*
*原材料新增
*/
namespace Admin\Func;

class Func904020201 {
    var  $db;
    var $rst;
    var $errmsg;
    var  $MaterialID;
    var  $MaterialCode;
    var  $MaterialName;
    var  $MaterialTypeID;
    var  $MaterialModel;
    var  $MaterialUnit;
    var  $MaterialIMG;
    var  $MaterialSIMG;
    var  $MaterialDesc;

    public function __construct($MaterialID,$MaterialCode,$MaterialName,$MaterialTypeID,$MaterialModel,$MaterialUnit,$MaterialIMG,$MaterialSIMG,$MaterialDesc) {
        $this->db  = new \Think\Model();
        $this->errmsg = '';
        $this->MaterialID = addslashes($MaterialID);
        $this->MaterialCode = addslashes($MaterialCode);
        $this->MaterialName = addslashes($MaterialName);
        $this->MaterialTypeID = addslashes($MaterialTypeID);
        $this->MaterialModel = addslashes($MaterialModel);
        $this->MaterialUnit = addslashes($MaterialUnit);
        $this->MaterialIMG = addslashes($MaterialIMG);
        $this->MaterialSIMG = addslashes($MaterialSIMG);
        $this->MaterialDesc = addslashes($MaterialDesc);

    }
    /*
    *获取错误信息
    */
    public function getErrMsg() {
        return $this->errmsg;
    }
    /*
    *验证
    */
    private function validate(){
        return true;
    }
    /*
    *执行
    */
    public function execute(){
        $vflag = true;
        $OperID = I('OperID');
        if($this->validate()){

            $sql = <<<EOD
INSERT INTO t_lz_ps_material(
MaterialID,
MaterialCode,
MaterialName,
MaterialTypeID,
MaterialModel,
MaterialUnit,
MaterialIMG,
MaterialSIMG,
MaterialDesc,

        OperID,
        OperDate
        )values(
        '$this->MaterialID',
        '$this->MaterialCode',
        '$this->MaterialName',
        '$this->MaterialTypeID',
        '$this->MaterialModel',
        '$this->MaterialUnit',
        '$this->MaterialIMG',
        '$this->MaterialSIMG',
        '$this->MaterialDesc',

        '$OperID',
        now()
)

EOD;

            //$this->rst = $this->db->query($sql);
            $this->rst = $this->db->execute($sql);
            if ($this->rst === false){
                $this->errmsg = $this->db->getDbError();
                $vflag = false;
            }else{
                $vflag = true;  
            }
        }else{
            $vflag = false;
        }
    return  $vflag;
    }
    public function getRst(){
        return $this->rst;
    }
}
